//
//  MainMusicTableViewCell.m
//  WXMusic
//
//  Created by 漫步人生路 on 15/8/31.
//  Copyright (c) 2015年 漫步人生路. All rights reserved.
//

#import "MainMusicTableViewCell.h"

@implementation MainMusicTableViewCell
//实现初始化方法
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        //将Cell的背景色设置为透明
        self.backgroundColor = [UIColor clearColor];
        //创建ScrollView
        self.recommendedScrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, kWidth, 260)];
        //设置ScrollView的属性
        [self setUpScrollView:self.recommendedScrollView];
        [self.contentView addSubview:self.recommendedScrollView];

    }
    return self;
}
- (void)setUpImageViewWithTaget:(id)taget action:(SEL)action imageArray:(NSMutableArray *)imageArray model:(RecommendModel *)model
{
    //循环创建tapImageView
    for (int i = 0; i < imageArray.count; i ++) {
        model = [imageArray objectAtIndex:i];
        TapImageView *tapImageView = [[TapImageView alloc]initWithFrame:CGRectMake(i * (kWidth/2) + 15 , 15, kWidth/2-45, kWidth/2 -45) taget:taget action:action];
        //设置tapImageView的tag
        //使用1000+i是为了避免被系统占用
        tapImageView.tag = 1000 + i;
        //获取图片
        [tapImageView sd_setImageWithURL:[NSURL URLWithString:model.pic]];
        
        [self setUpImageView:tapImageView];
        [self.recommendedScrollView addSubview:tapImageView];
    }
}
//设置imageView的layer
- (void)setUpImageView:(TapImageView *)imageView
{
    //允许设置
    imageView.layer.masksToBounds = YES;
    imageView.layer.borderWidth = 2;
    imageView.layer.cornerRadius = imageView.bounds.size.height / 2;
    imageView.layer.borderColor = [[UIColor whiteColor] CGColor];
}
//设置ScrollView的属性
- (void)setUpScrollView:(UIScrollView *)scrollView
{
    scrollView.pagingEnabled = YES;
    scrollView.showsHorizontalScrollIndicator = NO;
    scrollView.bounces = NO;
    scrollView.contentSize = CGSizeMake(kWidth * 2, 0);
    
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
